import 'package:flutter/material.dart';
import 'package:flutter_vlc_player/flutter_vlc_player.dart';

import '../common/flatPanel.dart';
import '../entry.dart';

class VlcPlayerPage extends StatefulWidget {
  @override
  _VlcPlayerPageState createState() => _VlcPlayerPageState();
}

// https://pub.flutter-io.cn/packages/flutter_vlc_player
class _VlcPlayerPageState extends State<VlcPlayerPage> {
  VlcPlayerController _videoPlayerController;
  final videoUrl =
      'https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4';

  @override
  void initState() {
    super.initState();
    _videoPlayerController = VlcPlayerController.network(videoUrl,
        hwAcc: HwAcc.AUTO, autoPlay: false, options: VlcPlayerOptions());
  }

  @override
  void dispose() async {
    // TODO: implement dispose
    super.dispose();
    await _videoPlayerController.stopRendererScanning();
  }

  @override
  Widget build(BuildContext context) {
    return FlatScaffold(
      Entry.VlcPlayer,
      child: VlcPlayer(
        controller: _videoPlayerController,
        aspectRatio: 16 / 9,
        placeholder: Center(child: CircularProgressIndicator()),
      ),
    );
  }
}
